#include <stdio.h>

int main(int i, char c)
{
	for(scanf("%d\n",&i);~scanf("%c %d\n",&c,&i);)
	{
		if(c=='C')
			i=(9/5.)*i+32;
		else
			i=(5/9.)*(i-32);
		printf("%d\n",i);
	}
}
